function clickContent(index){
	contentNow = index;
	$(".active").removeClass("active");
	$("#c_"+index).addClass("active");
	$(".content").slideUp();
	$("#content_"+index).slideDown();
	switch(index){
		case 1: showCompany(1); break;
		case 2: showSuperMarket(1); break;
		case 3: showBrand(1); break;
		case 4: showProduct(1); break;
		case 5: showInfo(); break;
	}
}

var companyId = null;
var marketId = null;
var brandId = null;
var productId = null;

function saveContent(type){
	switch(type){
	case 1: 
		companyId = "";
		$('[name="companyRadio"]:radio').each(function() {
			if(this.checked){
				companyId = $(this).val();
			}
		});
		clickContent(2);
		break;
	case 2: 
		marketId = "";
		$('[name="marketRadio"]:radio').each(function() {
			if(this.checked){
				marketId = $(this).val();
			}
		});
		clickContent(3);
		break;
	case 3: 
		brandId = "";
		$('[name="brandRadio"]:radio').each(function() {
			if(this.checked){
				brandId = $(this).val();
			}
		});
		clickContent(4);
		break;
	case 4: 
		productId = "";
		$('[name="productRadio"]:radio').each(function() {
			if(this.checked){
				productId = $(this).val();
			}
		});
		clickContent(5);
		break;
	case 5: 
		productId = "";
		$('[name="productRadio"]:radio').each(function() {
			if(this.checked){
				productId = $(this).val();
			}
		});
	break;
	}
}

function showCompany(pageNow){
	var tmp2=root+"/admin/company!findCompanyByP";
	$.ajax({
		url: tmp2,
		type: "POST",
		async:false,
		data:{"page.curPageNum":pageNow, "isDesc": isDesc},
		dataType:"json",
		success: function(json){
			var htmlStr = '';
			for(var i=0; i<json.pageData.length; i++){
				if(companyId!=null){
					if(companyId==json.pageData[i].id){
						htmlStr += '<li><label><input type="radio" name="companyRadio" value="'+json.pageData[i].id+'" checked="checked" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}else{
						htmlStr += '<li><label><input type="radio" name="companyRadio" value="'+json.pageData[i].id+'" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}
				}else{
					htmlStr += '<li><label><input type="radio" name="companyRadio" value="'+json.pageData[i].id+'" />';
					htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
				}
			}
			htmlStr += '<li style="text-align: left; cursor: pointer; width: 85%; border-bottom:none;">';
			htmlStr += '<span onclick="showCompany('+1+')">首页</span>';
			if(json.curPageNum>1){
				htmlStr += '<span onclick="showCompany('+(json.curPageNum-1)+')">上一页</span>';
			}else{
				htmlStr += '<span>上一页</span>';
			}
			if((json.curPageNum+1)<=json.totalPageNum){
				htmlStr += '<span onclick="showCompany('+(json.curPageNum+1)+')">下一页</span>';
			}else{
				htmlStr += '<span>下一页</span>';
			}
			htmlStr += '<span onclick="showCompany('+json.totalPageNum+')">尾页</span>';
			htmlStr += '<span>('+json.curPageNum+'/'+json.totalPageNum+')</span>';
			htmlStr += '</li>';
			htmlStr += '<li style="text-align: right; cursor: pointer; width: 15%;">';
			htmlStr += '<span onclick="saveContent(1)">下一步</span></li>';
			$("#companyUl").html(htmlStr);
		}
	});
}

function showSuperMarket(pageNow){
	var tmp2=root+"/admin/super-market!findSuperMarketByCompanyId";
	$.ajax({
		url: tmp2,
		type: "POST",
		async:false,
		data:{"page.curPageNum":pageNow, "isDesc": isDesc, "company.id":companyId, "page.numberPerPage": 20},
		dataType:"json",
		success: function(json){
			var htmlStr = '';
			for(var i=0; i<json.pageData.length; i++){
				if(marketId!=null){
					if(marketId==json.pageData[i].id){
						htmlStr += '<li><label><input type="radio" name="marketRadio" value="'+json.pageData[i].id+'" checked="checked" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}else{
						htmlStr += '<li><label><input type="radio" name="marketRadio" value="'+json.pageData[i].id+'" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}
				}else{
					htmlStr += '<li><label><input type="radio" name="marketRadio" value="'+json.pageData[i].id+'" />';
					htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
				}
			}
			htmlStr += '<li style="text-align: left; cursor: pointer; width: 75%; border-bottom:none;">';
			htmlStr += '<span onclick="showSuperMarket('+1+')">首页</span>';
			if(json.curPageNum>1){
				htmlStr += '<span onclick="showSuperMarket('+(json.curPageNum-1)+')">上一页</span>';
			}else{
				htmlStr += '<span>上一页</span>';
			}
			if((json.curPageNum+1)<=json.totalPageNum){
				htmlStr += '<span onclick="showSuperMarket('+(json.curPageNum+1)+')">下一页</span>';
			}else{
				htmlStr += '<span>下一页</span>';
			}
			htmlStr += '<span onclick="showSuperMarket('+json.totalPageNum+')">尾页</span>';
			htmlStr += '<span>('+json.curPageNum+'/'+json.totalPageNum+')</span>';
			htmlStr += '</li>';
			htmlStr += '<li style="text-align: right; cursor: pointer; width: 25%;">';
			htmlStr += '<span onclick="clickContent(1)">上一步</span><span onclick="saveContent(2)">下一步</span></li>';
			$("#marketUl").html(htmlStr);
		}
	});
}

function showBrand(pageNow){
	var tmp2=root+"/admin/brand!findBrandByPage";
	$.ajax({
		url: tmp2,
		type: "POST",
		async:false,
		data:{"page.curPageNum":pageNow, "isDesc": isDesc, "page.numberPerPage": 20},
		dataType:"json",
		success: function(json){
			var htmlStr = '';
			for(var i=0; i<json.pageData.length; i++){
				if(brandId!=null){
					if(brandId==json.pageData[i].id){
						htmlStr += '<li><label><input type="radio" name="brandRadio" value="'+json.pageData[i].id+'" checked="checked" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}else{
						htmlStr += '<li><label><input type="radio" name="brandRadio" value="'+json.pageData[i].id+'" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}
				}else{
					htmlStr += '<li><label><input type="radio" name="brandRadio" value="'+json.pageData[i].id+'" />';
					htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
				}
			}
			htmlStr += '<li style="text-align: left; cursor: pointer; width: 75%; border-bottom:none;">';
			htmlStr += '<span onclick="showBrand('+1+')">首页</span>';
			if(json.curPageNum>1){
				htmlStr += '<span onclick="showBrand('+(json.curPageNum-1)+')">上一页</span>';
			}else{
				htmlStr += '<span>上一页</span>';
			}
			if((json.curPageNum+1)<=json.totalPageNum){
				htmlStr += '<span onclick="showBrand('+(json.curPageNum+1)+')">下一页</span>';
			}else{
				htmlStr += '<span>下一页</span>';
			}
			htmlStr += '<span onclick="showBrand('+json.totalPageNum+')">尾页</span>';
			htmlStr += '<span>('+json.curPageNum+'/'+json.totalPageNum+')</span>';
			htmlStr += '</li>';
			htmlStr += '<li style="text-align: right; cursor: pointer; width: 25%;">';
			htmlStr += '<span onclick="clickContent(2)">上一步</span><span onclick="saveContent(3)">下一步</span></li>';
			$("#brandUl").html(htmlStr);
		}
	});
}

function showProduct(pageNow){
	var tmp2=root+"/admin/product!findProductByPage";
	$.ajax({
		url: tmp2,
		type: "POST",
		async:false,
		data:{"page.curPageNum":pageNow, "isDesc": isDesc, "brand.id":brandId, "product.name": ""},
		dataType:"json",
		success: function(json){
			var htmlStr = '';
			for(var i=0; i<json.pageData.length; i++){
				if(productId!=null){
					if(productId==json.pageData[i].id){
						htmlStr += '<li><label><input type="radio" name="productRadio" value="'+json.pageData[i].id+'" checked="checked" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}else{
						htmlStr += '<li><label><input type="radio" name="productRadio" value="'+json.pageData[i].id+'" />';
						htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
					}
				}else{
					htmlStr += '<li><label><input type="radio" name="productRadio" value="'+json.pageData[i].id+'" />';
					htmlStr += '&nbsp;&nbsp;&nbsp;'+json.pageData[i].name+'</lable></li>';
				}
			}
			htmlStr += '<li style="text-align: left; cursor: pointer; width: 75%; border-bottom:none;">';
			htmlStr += '<span onclick="showProduct('+1+')">首页</span>';
			if(json.curPageNum>1){
				htmlStr += '<span onclick="showProduct('+(json.curPageNum-1)+')">上一页</span>';
			}else{
				htmlStr += '<span>上一页</span>';
			}
			if((json.curPageNum+1)<=json.totalPageNum){
				htmlStr += '<span onclick="showProduct('+(json.curPageNum+1)+')">下一页</span>';
			}else{
				htmlStr += '<span>下一页</span>';
			}
			htmlStr += '<span onclick="showProduct('+json.totalPageNum+')">尾页</span>';
			htmlStr += '<span>('+json.curPageNum+'/'+json.totalPageNum+')</span>';
			htmlStr += '</li>';
			htmlStr += '<li style="text-align: right; cursor: pointer; width: 25%;">';
			htmlStr += '<span onclick="clickContent(3)">上一步</span><span onclick="saveContent(4)">下一步</span></li>';
			$("#productUl").html(htmlStr);
		}
	});
}

function showInfo(){
	
}